#include <iostream>
using std::cout;
using std::endl;

int num = 100;

class Point
{
public:
    Point(int x,int y,int z)
    : _ix(x)
    , _iy(y)
    //引用数据成员的生命周期和对象一样长
    //需要去绑定一个已经存在并且在对象的生命周期内始终存在的变量
    /* , _iz(z) */
    , _iz(num)
    {
        /* &z; */
        cout << "Point(int,int)" << endl;
    }

    ~Point(){
        cout << "~Point()" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    , _iz(_ix)
    {
        cout << "Point(const Point&)" << endl;
    }


    void print(){
        cout << "(" << _ix
            << "," << _iy
            << "," << _iz
            << ")" << endl;
    }
private:
    int _ix;
    int _iy;
    int & _iz = _ix;//c++11
};


void test0(){
    Point pt(3,5,6);
    pt.print();
}

int main(void){
    test0();
    return 0;
}
